cd "1_Media Content Analysis"

log using "./log files/figs1_A1.txt", replace

set scheme s1color

/* In-text Summaries*/
use "./data/media_frequency.dta", clear

format date %td
label var Freq_Fox "Fox"
label var Freq_MSNBC "MSNBC"

su Freq* if index >= 115 & index < 145 & df == "counts"
su Freq* if index >= 145 & index < 177 & df == "counts"

di (24-4)/4
di (20-5)/5

su Freq* if index >= 245 & index <= 274 & df == "counts"

/* Figure 1*/
use "./data/media_frames.dta", clear

format date %td
label var Freq_Fox "Fox"
label var Freq_MSNBC "MSNBC"

/* Activism */
twoway (scatter Freq_Fox index if index<145 & df == "prop" & frame == "activism", mcolor(gs13) msize(small) msymbol(S))(scatter Freq_Fox index if index>145 & df == "prop" & frame == "activism", mcolor(gs13) msize(small) msymbol(S)) ///
(scatter Freq_MSNBC index if index<145 & df == "prop" & frame == "activism", msize(small) mcolor(gs5))(scatter Freq_MSNBC index if index>145 & df == "prop" & frame == "activism", msize(small) mcolor(gs5)) ///
(lowess Freq_Fox index if index<145 & df == "prop" & frame == "activism", lwidth(thick) lcolor(gs13) msymbol(S))(lowess Freq_Fox index if index>145 & df == "prop" & frame == "activism", lcolor(gs13) lwidth(thick)) ///
(lowess Freq_MSNBC index if index<145 & df == "prop" & frame == "activism", lwidth(thick) lpattern(dash) lcolor(gs5))(lowess Freq_MSNBC index if index>145 & df == "prop" & frame == "activism", lcolor(gs5) lwidth(thick) lpattern(dash)), ///
ylabel(,nogrid) xlabel(1 "Jan" 32 "Feb" 61 "Mar" 92 "Apr" 122 "May" 153 "Jun" 183 "Jul" 214 "Aug" 245 "Sept" 275 "Oct" 306 "Nov" 336 "Dec", labsize(small)) xtitle(" ") ytitle("Proportion") title("Daily Proportion of Mentions""of Blacks containing""Activism Frame per Network") ///
xline(145, lcolor(red)) legend(order(1 3)) name("Activprops", replace)

twoway (scatter Freq_Fox index if index<145 & df == "counts" & frame == "activism", msize(small) mcolor(gs13) msymbol(S))(scatter Freq_Fox index if index>145 & df == "counts" & frame == "activism", msize(small) mcolor(gs13) msymbol(S)) ///
(scatter Freq_MSNBC index if index<145 & df == "counts" & frame == "activism", msize(small) mcolor(gs5))(scatter Freq_MSNBC index if index>145 & df == "counts" & frame == "activism", msize(small) mcolor(gs5)) ///
(lowess Freq_Fox index if index<145 & df == "counts" & frame == "activism", lwidth(thick) lcolor(gs13) msymbol(S))(lowess Freq_Fox index if index>145 & df == "counts" & frame == "activism", lcolor(gs13) lwidth(thick)) ///
(lowess Freq_MSNBC index if index<145 & df == "counts" & frame == "activism", lwidth(thick) lpattern(dash) lcolor(gs5))(lowess Freq_MSNBC index if index>145 & df == "counts" & frame == "activism", lcolor(gs5) lwidth(thick) lpattern(dash)), ///
ylabel(,nogrid) xlabel(1 "Jan" 32 "Feb" 61 "Mar" 92 "Apr" 122 "May" 153 "Jun" 183 "Jul" 214 "Aug" 245 "Sept" 275 "Oct" 306 "Nov" 336 "Dec", labsize(small)) xtitle(" ") ytitle("Count") title("  ""Daily Counts of Activism Frames""in Episodes per Network") ///
xline(145, lcolor(red)) legend(order(1 3)) name("Activcounts", replace)

twoway (scatter Freq_Fox index if index<145 & df == "prop" & frame == "backlash", mcolor(gs13) msize(small) msymbol(S))(scatter Freq_Fox index if index>145 & df == "prop" & frame == "backlash", mcolor(gs13) msize(small) msymbol(S)) ///
(scatter Freq_MSNBC index if index<145 & df == "prop" & frame == "backlash", msize(small) mcolor(gs5))(scatter Freq_MSNBC index if index>145 & df == "prop" & frame == "backlash", msize(small) mcolor(gs5)) ///
(lowess Freq_Fox index if index<145 & df == "prop" & frame == "backlash", lwidth(thick) lcolor(gs13) msymbol(S))(lowess Freq_Fox index if index>145 & df == "prop" & frame == "backlash", lcolor(gs13) lwidth(thick)) ///
(lowess Freq_MSNBC index if index<145 & df == "prop" & frame == "backlash", lwidth(thick) lpattern(dash) lcolor(gs5))(lowess Freq_MSNBC index if index>145 & df == "prop" & frame == "backlash", lcolor(gs5) lwidth(thick) lpattern(dash)), ///
ylabel(,nogrid) xlabel(1 "Jan" 32 "Feb" 61 "Mar" 92 "Apr" 122 "May" 153 "Jun" 183 "Jul" 214 "Aug" 245 "Sept" 275 "Oct" 306 "Nov" 336 "Dec", labsize(small)) xtitle(" ") ytitle("Proportion") title("Daily Proportion of Mentions""of Blacks containing""Backlash Frame per Network") ///
xline(145, lcolor(red)) legend(order(1 3)) name("Backprops", replace)

twoway (scatter Freq_Fox index if index<145 & df == "counts" & frame == "backlash", msize(small) mcolor(gs13) msymbol(S))(scatter Freq_Fox index if index>145 & df == "counts" & frame == "backlash", msize(small) mcolor(gs13) msymbol(S)) ///
(scatter Freq_MSNBC index if index<145 & df == "counts" & frame == "backlash", msize(small) mcolor(gs5))(scatter Freq_MSNBC index if index>145 & df == "counts" & frame == "backlash", msize(small) mcolor(gs5)) ///
(lowess Freq_Fox index if index<145 & df == "counts" & frame == "backlash", lwidth(thick) lcolor(gs13) msymbol(S))(lowess Freq_Fox index if index>145 & df == "counts" & frame == "backlash", lcolor(gs13) lwidth(thick)) ///
(lowess Freq_MSNBC index if index<145 & df == "counts" & frame == "backlash", lwidth(thick) lpattern(dash) lcolor(gs5))(lowess Freq_MSNBC index if index>145 & df == "counts" & frame == "backlash", lcolor(gs5) lwidth(thick) lpattern(dash)), ///
ylabel(,nogrid) xlabel(1 "Jan" 32 "Feb" 61 "Mar" 92 "Apr" 122 "May" 153 "Jun" 183 "Jul" 214 "Aug" 245 "Sept" 275 "Oct" 306 "Nov" 336 "Dec", labsize(small)) xtitle(" ") ytitle("Count") title("  ""Daily Counts of Backlash Frames""in Episodes per Network") ///
xline(145, lcolor(red)) legend(order(1 3)) name("Backcounts", replace)

/*combined figure*/
graph combine Activcounts Activprops, note("Lowess smoothing")
graph export "./figures/Figure1a.pdf", replace

graph combine Backcounts Backprops, note("Lowess smoothing")
graph export "./figures/Figure1b.pdf", replace

/* Figure A1*/
use "./data/media_frequency.dta", clear

format date %td
label var Freq_Fox "Fox"
label var Freq_MSNBC "MSNBC"

twoway (scatter Freq_Fox index if index<145 & df == "prop", mcolor(gs13) msize(small) msymbol(S))(scatter Freq_Fox index if index>145 & df == "prop", mcolor(gs13) msize(small) msymbol(S)) ///
(scatter Freq_MSNBC index if index<145 & df == "prop", msize(small) mcolor(gs5))(scatter Freq_MSNBC index if index>145 & df == "prop", msize(small) mcolor(gs5)) ///
(lowess Freq_Fox index if index<145 & df == "prop", lwidth(thick) lcolor(gs13) msymbol(S))(lowess Freq_Fox index if index>145 & df == "prop", lcolor(gs13) lwidth(thick)) ///
(lowess Freq_MSNBC index if index<145 & df == "prop", lwidth(thick) lpattern(dash) lcolor(gs5))(lowess Freq_MSNBC index if index>145 & df == "prop", lcolor(gs5) lwidth(thick) lpattern(dash)), ///
ylabel(,nogrid) xlabel(1 "Jan" 32 "Feb" 61 "Mar" 92 "Apr" 122 "May" 153 "Jun" 183 "Jul" 214 "Aug" 245 "Sept" 275 "Oct" 306 "Nov" 336 "Dec", labsize(small)) xtitle(" ") ytitle("Proportion") title("Mentions as Share of""Total Daily Discussion") ///
xline(145, lcolor(red)) legend(order(1 3)) name("props", replace)

twoway (scatter Freq_Fox index if index<145 & df == "counts", msize(small) mcolor(gs13) msymbol(S))(scatter Freq_Fox index if index>145 & df == "counts", msize(small) mcolor(gs13) msymbol(S)) ///
(scatter Freq_MSNBC index if index<145 & df == "counts", msize(small) mcolor(gs5))(scatter Freq_MSNBC index if index>145 & df == "counts", msize(small) mcolor(gs5)) ///
(lowess Freq_Fox index if index<145 & df == "counts", lwidth(thick) lcolor(gs13) msymbol(S))(lowess Freq_Fox index if index>145 & df == "counts", lcolor(gs13) lwidth(thick)) ///
(lowess Freq_MSNBC index if index<145 & df == "counts", lwidth(thick) lpattern(dash) lcolor(gs5))(lowess Freq_MSNBC index if index>145 & df == "counts", lcolor(gs5) lwidth(thick) lpattern(dash)), ///
ylabel(,nogrid) xlabel(1 "Jan" 32 "Feb" 61 "Mar" 92 "Apr" 122 "May" 153 "Jun" 183 "Jul" 214 "Aug" 245 "Sept" 275 "Oct" 306 "Nov" 336 "Dec", labsize(small)) xtitle(" ") ytitle("Count") title("  ""Number of Mentions") ///
xline(145, lcolor(red)) legend(order(1 3)) name("counts", replace)


/*combined figure*/
graph combine counts props, note("Lowess smoothing")
graph export "./figures/FigureA1.pdf", replace

capture log close
